<?php

class AdminModel extends Model{

 public $table='admin';
         public function userLogin($data){

             if(empty($data['username'])){
             	$this->error='用户名不能为空';
             	return false;
             }
             if(empty($data['password'])){

             	$this->error='密码不能为空';
             	return false;
             }
              // p($data);exit;
            $user=$this->where("username='{$data['username']}'")->find();
            if(empty($user)){
            	$this->error='用户不存在';
            	return false;
            }
           
            if(md5($data['password'])!=$user['password']){
            	$this->error='密码不正确';
            	return false;

            }
                $_SESSION['aid']=$user['aid'];
                $_SESSION['username']=$user['username'];
                return true;
         }

}



?>